package com.dc.designPattern._11_proxy.extend.extend1;

import lombok.Data;

import java.util.Objects;

/**
 * Description: 被代理者_游戏玩家
 * @author: gdc
 * @date: 2021/6/24
 * @version 1.0
 */
@Data
public class GamePlayer implements IGamePlayer {

    /**
     * 用户名
     */
    private String name;

    /**
     * 构造函数限制谁能创建对象，并同时传递姓名
     * @param gamePlayer
     * @param name
     */
    public GamePlayer(IGamePlayer gamePlayer, String name) {
        if (Objects.isNull(gamePlayer)) {
            throw new IllegalArgumentException("不能创建真实角色！");
        }
        this.name = name;
    }

    @Override
    public void login(String user, String pwd) {
        System.out.println("登陆名：" + user + "的用户 " + getName() + " 完成登陆");
    }

    @Override
    public void killBoss() {
        System.out.println(getName() + "，在打怪...");
    }

    @Override
    public void upgrade() {
        System.out.println(getName() + ", 又升了一级...");
    }
}
